<?php

class CalendarHelper extends Helper
{
	var $helpers = array('EditForm');

	function init() { }

	function setup()
	{
        /*
        todo: Сделать обработку параметров fromDateId и toDateId
        есть такой примерчик с сайта

        <script type="text/javascript">
            function catcalc(cal) {
                var date = cal.date;
                var time = date.getTime()
                // use the _other_ field
                var field = document.getElementById("f_calcdate");
                if (field == cal.params.inputField) {
                    field = document.getElementById("f_date_a");
                    time -= Date.WEEK; // substract one week
                } else {
                    time += Date.WEEK; // add one week
                }
                var date2 = new Date(time);
                field.value = date2.print("%Y-%m-%d %H:%M");
            }
            Calendar.setup({
                inputField     :    "f_date_a",
                ifFormat       :    "%Y-%m-%d %H:%M",
                showsTime      :    true,
                timeFormat     :    "24",
                onUpdate       :    catcalc
            });
            Calendar.setup({
                inputField     :    "f_calcdate",
                ifFormat       :    "%Y-%m-%d %H:%M",
                showsTime      :    true,
                timeFormat     :    "24",
                onUpdate       :    catcalc
            });
        </script>
        */
	}

	/**
	 * Generates date(or datetime) field based on $form->input()
	 *
	 * @param string $fieldName
	 * @param boolean $showTime
	 * @param array() $options - Options array passed to $form->input()
	 * @param boolean $readOnly
	 * @return unknown
	 */
	function date($fieldName, $showTime = false, $options = array(), $readOnly = false, $fromDateId = null, $toDateId = null)
	{
	    $args =& func_get_args();

	    return call_user_func_array(array(&$this->EditForm, 'calendar'), $args);
	}

}

?>